package org.apache.flink.runtime.rest.messages.taskmanager;

import org.apache.flink.runtime.rest.HttpMethodWrapper;
import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
import org.apache.flink.runtime.rest.messages.RuntimeMessageHeaders;
import org.apache.flink.runtime.rest.messages.ThreadDumpInfo;
import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;

public class ResourceProviderThreadDumpHeaders
        implements RuntimeMessageHeaders<
                EmptyRequestBody, ThreadDumpInfo, ResourceProviderMessageParameters> {

    private static final ResourceProviderThreadDumpHeaders INSTANCE = new ResourceProviderThreadDumpHeaders();

    private static final String URL =
            String.format("/resourceproviders/:%s/thread-dump", ResourceProviderIdPathParameter.KEY);

    private ResourceProviderThreadDumpHeaders() {}

    @Override
    public Class<EmptyRequestBody> getRequestClass() {
        return EmptyRequestBody.class;
    }

    @Override
    public ResourceProviderMessageParameters getUnresolvedMessageParameters() {
        return new ResourceProviderMessageParameters();
    }

    @Override
    public HttpMethodWrapper getHttpMethod() {
        return HttpMethodWrapper.GET;
    }

    @Override
    public String getTargetRestEndpointURL() {
        return URL;
    }

    public static ResourceProviderThreadDumpHeaders getInstance() {
        return INSTANCE;
    }

    @Override
    public Class<ThreadDumpInfo> getResponseClass() {
        return ThreadDumpInfo.class;
    }

    @Override
    public HttpResponseStatus getResponseStatusCode() {
        return HttpResponseStatus.OK;
    }

    @Override
    public String getDescription() {
        return "Returns the thread dump of the requested TaskManager.";
    }
}
